<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\common\widgets\MyFileUpload;

/* @var $this yii\web\View */
/* @var $model app\models\GkyQyhUser */
/* @var $form yii\widgets\ActiveForm */
?>

<script type="text/javascript" src="js/qiniuupload/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/qiniuupload/plupload/plupload.full.min.js"></script>
<script type="text/javascript" src="js/qiniuupload/plupload/i18n/zh_CN.js"></script>
<script type="text/javascript" src="js/qiniuupload/ui.js"></script>
<script type="text/javascript" src="js/qiniuupload/qiniu.js"></script>
<script type="text/javascript" src="js/qiniuupload/highlight/highlight.js"></script>
<script type="text/javascript" src="js/qiniuupload/main.js"></script>


<div class="gky-qyh-user-form">
    <div class="panel panel-default">
        <div class="panel-body">
            <?php
            $form = ActiveForm::begin([
                        'options' => ['class' => 'form-horizontal form-group'],
                        'fieldConfig' => [
                            'template' => "{label}<div class=\"col-lg-8\">{input}</div>",
                            'labelOptions' => ['class' => 'col-lg-4', 'style' => 'margin-right:-30px'],
                        ]
            ]);
            ?>



            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
                <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
            </div>

            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
                <?= $form->field($model, 'userid')->textInput(['maxlength' => true]) ?>
            </div>

            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
                <div class="form-group field-gkyqyhuser-name">
                    <label class="col-lg-4" style="margin-right:-30px" for="gkyqyhuser-name">设置部门</label>
                    <div class="col-lg-8">
                        <?Php
                        $datas = \app\models\GkyQyhDepartment::findMembers(\app\api\Constant::$GKY_CORPID);
                        $data1 = $datas[0]['items'];
                        $data2 = $data1[0]['items'];
                        $results = [];
                        foreach ($data2 as $value) {
                            $result["name"] = $value['name'];
                            $result["id"] = $value['id'];
                            $results[] = $result;
                        }
                        $listData = ArrayHelper::map($results, 'id', 'name');
                        ?>
                        <?php
                        $currenDdepartments = [];
                        foreach ($model->deptUsers as $deptUser) {
                            $currenDdepartments[] = $deptUser->dept_id;
                        }
                        echo \kartik\widgets\Select2::widget([
                            'name' => 'departments',
                            'value' => $currenDdepartments,
                            'data' => $listData,
                            'size' => \kartik\widgets\Select2::MEDIUM,
                            'options' => ['placeholder' => '请添加部门', 'multiple' => true],
                            'pluginOptions' => [
                                'tags' => true,
                                'allowClear' => true,
                            ],
                        ]);
                        ?>
                    </div>
                </div>           
            </div>





            <!--            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
            <?php // echo $form->field($model, 'position')->textInput(['maxlength' => true]) ?>
                        </div>-->
            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
                <?= $form->field($model, 'mobile')->textInput(['maxlength' => true]) ?>
            </div>
            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
                <?= $form->field($model, 'gender')->dropDownList(['1' => '男', '2' => '女'], ['prompt' => '请选择性别']) ?>
            </div>
            <!--            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
            <?php // echo  $form->field($model, 'weixinid')->textInput(['maxlength' => true]) ?>
                        </div>
                        <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
            <?php // echo  $form->field($model, 'avatar')->textInput(['maxlength' => true]) ?>
                        </div>
                        <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
            <?php // echo  $form->field($model, 'status')->textInput() ?>
                        </div>-->
            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
                <?php
                $data = \app\models\GkyQyh::find()->all();
                echo $form->field($model, 'qyh_id')->dropDownList(
                    \yii\helpers\ArrayHelper::map($data, 'id', 'qyhname'), ['prompt' => '请选择企业号'])->label('企业号');
                ?>
            </div>
            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
                <?= $form->field($model, 'graduate_school')->textInput() ?>
            </div>
            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
                <?= $form->field($model, 'xueli')->textInput() ?>
            </div>
            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
                <?= $form->field($model, 'xuewei')->textInput() ?>
            </div>
            <div class="col-lg-4 col-xs-12 col-sm-4 col-md-4">
                <?= $form->field($model, 'address')->textInput() ?>
            </div>
            
            <div class="col-lg-12 col-xs-12 col-sm-12 col-md-12">
                <?php echo "<font style='color:#333; font-size:14px; font-weight:bolder;'>签名图片</font>"?>
                <?php 
                    if($model->signature){
                        echo Html::img($model->signature,[]);
                    }
                ?>
                <?= MyFileUpload::widget() ?>
            </div>
            <div class="col-lg-12 col-xs-12 col-sm-12 col-md-12">
                <div class="form-group">
                    <?= Html::submitButton('保存', ['class' => 'btn btn-success col-lg-offset-5 col-md-offset-5']) ?>
                    <?= Html::a('返回', ['index'], ['class' => 'btn btn-primary']) ?>
                </div>
            </div>

            <?php ActiveForm::end(); ?>
        </div>
    </div>

</div>
